app.controller('BusCopyShiftCtrl', function ($scope, $modalInstance, $modal, param, ajax, $filter, toaster) {

	$scope.param = param;
	if ($scope.param.data == null) $scope.param.data = {};
	$scope.delayedFlag = param.data.shiftAttachedId > 0;
	$scope.timeRange = {};

	$scope.departTime = "00:00:00";

	$scope.ok = function () {
		if ($scope.myForm.$valid) {
			if ($scope.timeRange.startTime == null) {
				toaster.pop('warning', '提示', '请选择发班日期！');
				return;
			}
			if (!$scope.delayedFlag) {
				$scope.param.data.shiftAttachedId = 0;
			}
			var time = $scope.departTime;
			var date1 = new Date("1970/1/1 " + time);
			$scope.param.data.departTime = date1;
			$scope.param.data.departDate = $scope.timeRange.startTime;
			$scope.param.data.stationFilter = null;//防止json转换出错 实际并未修改filter
			$scope.param.data.template.stationFilter = null;
			$modalInstance.close($scope.param);
		}
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
	};
});